package MyStack;

import java.util.ArrayList;

/**
 * Created by abhijeet on 17/7/14.
 */
public class Stack {

    ArrayList<Integer> stack;
    int index;

    public Stack() {
        index = -1;
        stack = new ArrayList<Integer>(0);
    }

    public void push(int data) {
        index++;
        stack.add(index, data);
    }

    public int pop() {

        if (!stack.isEmpty()) {
            Integer data = stack.remove(index);
            index--;
            return data.intValue();
        } else {
            System.out.println("EMPTY STACK !");
            return -1;
        }
    }
}